1. 题目描述(简单难度)

[warning] 剑指 Offer 44. 数字序列中某一位的数字

2. 解法一:暴力 超出内存限制

class Solution {
    public int findNthDigit(int n) {
      StringBuilder sb = new StringBuilder();
      for(int i=0;i<=n;i++){
          sb.append(String.valueOf(i));
      }
      return sb.toString().charAt(n)-'0';
    }
}

3. 解法二:二分法



© gaohueric all right reserved,powered by Gitbook文件修订时间: 2021-12-08 23:22:22

results matching ""

    No results matching ""